<?php echo $this->load->view('meta'); ?>
<link rel="stylesheet" href="<?=base_url()?>css/admin.css" type="text/css" media="screen" />
<title>xa-ncsu | admin - groups</title>
<link rel="stylesheet" href="<?=base_url()?>css/impromptu.css" type="text/css" media="screen" />
<script type="text/javascript" src="<?=base_url();?>js/jquery-impromptu.1.2.js"></script>
<script type="text/javascript" language="JavaScript">
function vhconfirm(v,m)
        {
            if( v )
            {
                var f =  document.createElement("form");document.body.appendChild(f);f.method = "POST";f.action = $("#" + v ).attr( "href" );f.submit();
            } else
            {
                return false;
            }
        }
</script>
<?php echo $this->load->view('header'); ?>
<h3>Groups</h3>
<?php if ($groups->num_rows() > 0): ?>
<table>
<tr>
	<th>name</th>
	<th>description</th>
	<th>members</th>
	<th>leaders</th>
	<th>actions</th>
</tr>
<?php foreach ($groups->result() as $row) : ?>
<tr>
	<td><?=anchor('admin/groups/show/'.$row->groupid,$row->groupname)?></td>
	<td><?=$row->description?></td>
	<td><?=$row->members?></td>
	<td><?php if($row->leaders == "None"): ?>None<?php else: ?>
	<?php echo implode(', ', $row->leaders); ?>
	<?php endif; ?>
	</td>
	<td><a href="<?=site_url();?>mail/composeMail/group/<?=$row->groupid?>"><img src="<?=base_url();?>img/icons/email_go.png" alt="Email Group" title="Email Group" /></a>
		<a href="<?=site_url();?>admin/editGroup/<?=$row->groupid?>"><img src="<?=base_url();?>img/icons/group_edit.png" alt="Edit Group" title="Edit Group" /></a>
		<a href="<?=site_url();?>admin/deleteGroup/<?=$row->groupid?>" id="conf<?=$row->groupid?>" onclick="$.prompt('Delete Group?',{callback: vhconfirm, buttons: { Yes : 'conf<?=$row->groupid?>', No : false}}); return false;">
			<img src="<?=base_url();?>img/icons/delete.png" alt="Delete Group" title="Delete Group" /></a>
	</td>
</tr>
<?php endforeach; ?>
</table>
<?php endif; ?>

<form action="<?=site_url();?>admin/assign_user" method="post" class="h_form">
<fieldset>
	<legend>Group Membership</legend>
	<ol>
		<li><label for="userid">user</label>
		<?=form_dropdown('userid',$dropdown_users)?></li>
		<li><label for="groupid">group</label>
		<?=form_dropdown('groupid',$dropdown_groups)?></li>
		<li><label for="rank">rank</label>
		<?=form_dropdown('rank',$dropdown_rank)?><br /></li>
		<li class="submit_button"><label for="submit"><br /></label>
		<?=form_submit('','submit') ?></li>	
	</ol>
</fieldset>
</form>

<form action="<?=site_url();?>admin/createGroup" method="post" >
<fieldset>
	<legend>Create Group</legend>
	<ol>
		<li><label for="groupname">name</label>
		<?=form_input('groupname')?></li>
		<li><label for="description">description</label>
		<?=form_input('description')?></li>
		<li class="submit_button"><label for="submit"><br /></label>
		<?=form_submit('','submit') ?></li>	
	</ol>
</fieldset>
</form>
<?php echo $this->load->view('footer'); ?>